package everydayone.generateParenthesis;

import java.util.LinkedList;
import java.util.List;

/**
 * @Date 2020/04/09
 * @author 王光浩
 * @Thinking 使用递归
 */
public class MyMethodFour {
	private List<String> ret=new LinkedList<String>();
	public List<String> generateParenthesis(int n) {
		helper(n,n,"");
		return ret;
	}
	private void helper(int left,int right,String tem) {
		if(left==0 && right==0) {
			ret.add(tem);
			return;
		}
		if(left>0)helper(left-1,right,tem+"(");
		if(right>left) helper(left,right-1,tem+")");
	}
}
